<?php include_once dirname(__FILE__).'/common/header.php'; ?>

<?php include_once dirname(__FILE__).'/common/menu.php'; ?>

var attr = <?php echo json_encode($attr) ?>;
var ctrlName = '<?php echo $ctrlName ?>';


list.statusFrm = function(r,msg,method){
    Ext.Msg.confirm('确认?',msg,function(btn) {
        if(btn != 'no') {
            ZM.ajax({
                url: list.baseUrl +  ctrlName + method,
                params:{customer_id:r.customer_id},
                mask:list.grid,
                success:function(res){
                    ZM.bo.msg('success!',res.detail);
                    list.grid.store.reload();
                }
            });
        }
    });
}


list.grid = new ZM.EditorGridPanel({
    url: list.baseUrl + 'customer/getCustomerList',
    region: 'center',
    columns:[
        {header:'ID',dataIndex:'customer_id'},
        {header:'姓名',dataIndex:'customer_name',filter:{}},
        {header:'手机号',dataIndex:'customer_phone',filter:{}},
        {header:'邮箱',dataIndex:'customer_email',filter:{}},
        {header:'公司名称',dataIndex:'customer_companey',filter:{}},
        {header:'状态',dataIndex:'customer_status',width:65,renderer:ZM.status,filter:{
            xtype:'combofield',
            options:[['','全部'],['0','禁用'],['1','激活']]
        }},
        {header:'注册时间',dataIndex:'customer_time_create',width:140,filter:{xtype:'daterangefield'}},
        {header:'最后登录时间',dataIndex:'customer_time_lastlogin',width:140,filter:{xtype:'daterangefield'}},
        {header:'最后操作时间',dataIndex:'customer_time_lastmodified',width:140},
        {header:'操作',renderer:function(v,p,r){
            var str = '';
            str += Ext.rd('租赁情况','fireRental',r,ctrlName + '/getCustomerRentalList');
            str += Ext.rd('重置秘密','fireReset',r,ctrlName + '/resetCustomerPassword');
            if(r.json.customer_status == '1') {
                str += Ext.rd('禁用','fireDisable',r,ctrlName + '/disableCustomer');
            } else {
                str += Ext.rd('激活','fireActive',r,ctrlName + '/activeCustomer');
            }
            return str;
        }}
    ]
});


list.grid.fireDisable = function(r) {
    var r = r.json;
    list.statusFrm(r,'确定要禁用用户['+r.customer_name+']?','/disableCustomer');
}

list.grid.fireActive = function(r) {
    var r = r.json;
    list.statusFrm(r,'确定要激活用户['+r.customer_name+']?','/activeCustomer');
}

list.grid.fireReset = function(r) {
    var r = r.json;
    list.statusFrm(r,'确定要重置用户['+r.customer_name+']?','/deleteCustomer');
}

list.grid.fireDetail = list.grid.fireRental = function(r) {
  var r = r.json;
  list.detail.baseParams = {'customer_id': r.customer_id};
  list.detail.show().ownerCt.doLayout();
  list.detail.get(0).load();
}

list.detail = new ZM.detailPanel({
  items: new ZM.EditorGridPanel({
    url: list.baseUrl + 'customer/getCustomerRentalList',
    baseParams:{},
    columns:[
        {header:'ID',dataIndex:'customer_id'},
        {header:'手机号',dataIndex:'customer_rental_phone',filter:{}},
        {header:'公司名称',dataIndex:'customer_rental_companey',filter:{}},
        {header:'姓名',dataIndex:'customer_rental_name',filter:{}},
        {header:'职务',dataIndex:'customer_rental_position',filter:{}},
        {header:'联系方式',dataIndex:'customer_rental_contract',filter:{}},
        {header:'邮箱',dataIndex:'customer_rental_email',filter:{}},
        {header:'租赁设备',dataIndex:'customer_rental_device_type',filter:{xtype:'combofield',options:[['全部']].concat(attr.rental_devices)}},
        {header:'租赁期限',dataIndex:'customer_rental_deadline',filter:{}},
        {header:'提交时间',dataIndex:'customer_rental_time_create',width:140,filter:{xtype:'daterangefield'}}
    ]
  })
});



<?php include_once dirname(__FILE__).'/common/layout.php'; ?>
list.grid.store.load();
<?php include_once dirname(__FILE__).'/common/footer.php'; ?>
